package com.city.parking;

import com.city.parking.util.Utils;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.DrawerLayout.DrawerListener;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

public class LeaseShowActivity extends FragmentActivity implements
        OnClickListener {
	private LeaseItem mItem;
    private TextView mTitle, mPrice, mContact, mPhone, mDuration, mExtra, mAddr, mDate;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_lease_show);
		TextView titleTv = (TextView) findViewById(R.id.nav_title);
	    titleTv.setText("租赁详情");

        ImageView back = (ImageView) findViewById(R.id.nav_ico_back);
        back.setOnClickListener(this);

        ImageView more = (ImageView) findViewById(R.id.nav_ico_more);
        more.setVisibility(View.GONE);
        initView();
	}
	
	private void initView() {
		//getIntent().setExtrasClassLoader(LeaseItem.class.getClassLoader());
		Bundle bundle = getIntent().getExtras();
        if (bundle == null) {
        	Utils.log("bad item data");
        	return;
        }
        bundle.setClassLoader(LeaseItem.class.getClassLoader());
        mItem = bundle.getParcelable("item");
        mTitle = (TextView) findViewById(R.id.lease_title);
        mTitle.setText(mItem.name);
        mPrice = (TextView) findViewById(R.id.lease_price);
        mPrice.setText(Utils.getFormatNumber(mItem.price));
        mContact = (TextView) findViewById(R.id.lease_contact_name);
        mContact.setText(mItem.contact);
        mPhone = (TextView) findViewById(R.id.lease_contact_number);
        mPhone.setText(mItem.phone);
        mDuration = (TextView) findViewById(R.id.lease_duration);
        mDuration.setText(mItem.duration+"");
        mAddr = (TextView) findViewById(R.id.lease_addr);
        mAddr.setText(mItem.getAddr());
        mExtra = (TextView) findViewById(R.id.lease_extra);
        mExtra.setText(mItem.extra);
        TextView type = (TextView) findViewById(R.id.lease_type);
        if (mItem.isOut)
        	type.setText("出租");
        else
        	type.setText("求租");
        mDate = (TextView) findViewById(R.id.lease_publish_date);
        mDate.setText(mItem.date);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.nav_ico_back:
			finish();
			break;

		default:
			break;
		}
	}

}
